<template>
    <MyHead title="个人中心" @click-left="goback"></MyHead>
    <div style="width: 100%;text-align: center; margin-top: 50px;">欢迎 {{ tel }} 登入</div>
    <div @click="out" style="width: 100%;text-align: center; margin-top: 50px;">退出登入</div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { info } from '../api/user'
import router from '@/router';
import { useCommon } from '@/hooks/useCommon'

const { goback } = useCommon()
const tel = ref()
const userid = localStorage.getItem('id')
const out = () => { 
    localStorage.clear()
    router.push('/')
 }

onMounted(() => {
    info(userid).then(res => {
        console.log(res)
        if (res.code == '200') {
            tel.value = res.data[0].tel
            console.log(tel)
        } else {
            router.push('/login')
        }
    })
})
</script>